package baidu.day06.doudizhu;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.TreeSet;

// Created: 08/08/2025, ChangJiang Ru
public class PokerGame1 {

    // Make the card related the number
    static HashMap<Integer, String> hm = new HashMap<>();
    static ArrayList<Integer> list = new ArrayList<>();

    static
    {
        // Prepare card
        String[] color = {"♣", "♥", "♦", "♣"};
        String[] number = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2"};

        // Detail
        int serialNumber = 1;
        for (String n : number)
        {
        for (String c : color)
        {
            hm.put(serialNumber, c + n);
            list.add(serialNumber);
            serialNumber++;
        }
        }

        hm.put(serialNumber, "BigJoker");
        list.add(serialNumber);
        serialNumber++;
        hm.put(serialNumber, "LittleJoker");
        list.add(serialNumber);
        /*
        System.out.println(hm);
        System.out.println(list);

         */
    }

    public PokerGame1()
    {
        // Arrange sequence
        Collections.shuffle(list);

        // Player get the Poker
        TreeSet<Integer> lord = new TreeSet<>();
        TreeSet<Integer> player1 = new TreeSet<>();
        TreeSet<Integer> player2 = new TreeSet<>();
        TreeSet<Integer> player3 = new TreeSet<>();

        for (int i = 0; i < list.size(); i++) {
            int serialNumber = list.get(i);

            if (i <= 2)
            {
                lord.add(serialNumber);
                continue;
            }

            if(i % 3 == 0)
            {
                player1.add(serialNumber);
            }
            else if(i % 3 == 1)
            {
                player2.add(serialNumber);
            }
            else
            {
                player3.add(serialNumber);
            }



        }
            // Look the every player poker
            lookPoker("Lord", lord);
            lookPoker("Jake", player1);
            lookPoker("Tom", player2);
            lookPoker("Nike", player3);
    }

    public void lookPoker(String name, TreeSet<Integer> ts)
    {
        System.out.println(name + ": ");
        for (int serialNumber : ts)
        {
            String poker = hm.get(serialNumber);
            System.out.print(poker + " ");
        }
        System.out.println();
    }
}
